#include<iostream>
#include<vector>
#include<string>
using namespace std;

bool canJump(vector<int>& nums) {
    if (nums[0] == 0 && nums.size() == 1) return true;
    int left = 0, right = 0;
    int maxright = nums[0];
    int i = 0;
    while (i < nums.size())
    {
        while (left <= i && i <= right)
        {
            if (nums[i] + i > maxright) maxright = nums[i] + i;
            if (maxright >= nums.size() - 1) return true;
            i++;
        }
        left = right + 1;
        right = maxright;
        if (left > right) return false;
    }
    return true;
}

int monotoneIncreasingDigits(int n) {
    string s(to_string(n));
    int flag = 0;
    for (int i = 0; i < s.size() - 1; i++)
    {
        if (s[i] > s[i + 1]) flag = 1;
    }
    if (flag == 0) return n;
    for (int i = 0; i < s.size() - 1; i++)
    {
        if (s[i] > s[i + 1])
        {
            if (i != 0 && s[i] == s[i - 1])
            {
                for (int j = i; j >= 0; j--)
                {
                    i = j;
                    if (j == 0 || s[j] != s[j - 1]) break;
                }
            }
            s[i] = s[i] - '0' - 1 + '0';
            for (int j = i + 1; j < s.size(); j++) s[j] = '9';
            break;
        }
    }
    if (s[0] == '0')
        s.erase(s.begin());
    return stoi(s);
}

int main()
{
    vector<int> v{ 200 };
    monotoneIncreasingDigits(101);
    //cout << canJump(v);
    string s(to_string(v[0]));
    s[0] = s[0] - '0' + 1 + '0';

	return 0;
}